<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%@page  import="java.util.Date" %>
 <%@page  import="java.text.SimpleDateFormat" %>
 <%@page  import="java.util.Calendar" %>
 <%
 	SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	Date date = new Date();
	Calendar cal = Calendar.getInstance();
	cal.setTime(date);
	
	cal.add(Calendar.DATE,30);
	
	date =cal.getTime();
	
	String startdate = format.format(date);
	out.print(startdate);
%>      
<!doctype html>
<html>

	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>图书详情</title>
		<link rel="stylesheet" href="${ pageContext.request.contextPath }/css/bootstrap.min.css" type="text/css" />
		<script src="${ pageContext.request.contextPath }/js/jquery-1.11.3.min.js" type="text/javascript"></script>
		<script src="${ pageContext.request.contextPath }/js/bootstrap.min.js" type="text/javascript"></script>
		<!-- 引入自定义css文件 style.css -->
		<link rel="stylesheet" href="${ pageContext.request.contextPath }/css/style.css" type="text/css" />
		<script language="javascript" type="text/javascript" src="resources/My97DatePicker/WdatePicker.js"></script>
		<style>
			body {
				margin-top: 20px;
				margin: 0 auto;
			}
			
			.carousel-inner .item img {
				width: 100%;
				height: 300px;
			}
		</style>
		<script type="text/javascript">
			function check(){
				alert($("#expeReturnTime").val());
				return ;
			}
			
			$(document).ready(function(){
				  $("form").submit(function(e){
					 
					  var reg = /^[0-9]*$/;
					  if (!reg.test($("#total").val())) {
					  alert("请输入正整数！")
					  return false;
					  }
					  
					  var inventory = $("#inventory").val();
					  var total = $("#total").val()
					  if(total==''){
						  alert("借阅数量不能为空！");
					    	return false;
					  }
					 
					  if(parseInt(total)>parseInt(inventory)){
					    	alert("借阅数量不能超过库存");
					    	return false;
					    }
					  
				    var expeReturnTime = $("#expeReturnTime").val()
				    if(expeReturnTime==''){
				    	alert("预期归还时间不能为空！");
				    	return false;
				    }
				    
				  });
				});
		</script>
	</head>

	<body>

		<%@ include file="menu.jsp" %>

		<div class="container">
			<div class="row">
				<div style="border: 1px solid #e4e4e4;width:930px;margin-bottom:10px;margin:0 auto;padding:10px;margin-bottom:10px;">
					<a href="${ pageContext.request.contextPath }/index.jsp">首页&nbsp;&nbsp;&gt;</a>
				</div>
				
			<form id="form1" action="${ pageContext.request.contextPath }/BookBorrowServlet" method="post">
				<input type="hidden" name="method" value="addBookBorrow" />
				<input type="hidden" name="book_id" value="${ p.book_id }" />
				<input type="hidden" name="book_name" value="${ p.book_name }" />
				<input type="hidden" name="inventory" id="inventory" value="${ p.inventory }" />
				<div style="margin:0 auto;width:950px;">
					<div class="col-md-6">
						<img style="opacity: 1;width:400px;height:350px;" title="" class="medium" src="${ pageContext.request.contextPath }/${ p.book_image}">
					</div>

					<div class="col-md-6">
						<div><strong>${ p.book_name }</strong></div>
						<div style="border-bottom: 1px dotted #dddddd;width:350px;margin:10px 0 10px 0;">
							<div>编号：${ p.book_number }</div>
						</div>

						 <div style="margin:10px 0 10px 0;">库存: <strong style="color:#ef0101;">${ p.inventory }</strong> 
						</div>

						<%--<div style="margin:10px 0 10px 0;">促销: <a target="_blank" title="限时抢购 (2014-07-30 ~ 2015-01-01)" style="background-color: #f07373;">限时抢购</a> </div>
 --%>
						<div style="padding:10px;border:1px solid #e7dbb1;width:330px;margin:15px 0 10px 0;;background-color: #fffee6;">

							<div style="border-bottom: 1px solid #faeac7;margin-top:20px;padding-left: 10px;">借阅数量:
								<input id="total" name="total" value="1" maxlength="4" size="10" type="text"> </div>
							<div style="border-bottom: 1px solid #faeac7;margin-top:20px;padding-left: 10px;">预期归还时间:
								<input style="height:26px" readonly="readonly" id="expeReturnTime" name="expeReturnTime" class="Wdate" value="<%=startdate%>" type="text" onClick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'%y-%M-%d %H:%m:%s',maxDate:'<%=startdate%>'})"> </div>
							<div style="margin:20px 0 10px 0;;text-align: center;">
								<!-- <a href="javascript:document.getElementById('form1').submit()"> -->
									<input style="background: url('./images/product.gif') no-repeat scroll 0 -600px rgba(0, 0, 0, 0);height:36px;width:127px;" value="申请图书"  type="submit">
								<!-- </a> --></div>
						</div>
						
					</div>
					</div>
				</form>
				<div class="clear"></div>
				<div style="width:950px;margin:0 auto;">
					<div style="background-color:#d3d3d3;width:930px;padding:10px 10px;margin:10px 0 10px 0;">
						<strong>图书介绍</strong>
					</div>

					<div>
						${ p.book_introduce }
					</div>

					<div style="background-color:#d3d3d3;width:930px;padding:10px 10px;margin:10px 0 10px 0;">
						<strong>图书参数</strong>
					</div>
					<div style="margin-top:10px;width:900px;">
						<table class="table table-bordered">
							<tbody>
								<tr class="active">
									<th colspan="2">基本参数</th>
								</tr>
								<tr>
									<th width="10%">作者</th>
									<td width="30%">${ p.book_author }</td>
								</tr>
								<tr>
									<th width="10%">上架时间</th>
									<td>${ p.book_createTime }</td>
								</tr>
								<tr>
									<th width="10%">库存</th>
									<td>${ p.inventory }</td>
								</tr>
							</tbody>
						</table>
					</div>

					<!-- <div style="background-color:#d3d3d3;width:900px;">
						<table class="table table-bordered">
							<tbody>
								<tr class="active">
									<th><strong>商品评论</strong></th>
								</tr>
								<tr class="warning">
									<th>暂无商品评论信息 <a>[发表商品评论]</a></th>
								</tr>
							</tbody>
						</table>
					</div>

					<div style="background-color:#d3d3d3;width:900px;">
						<table class="table table-bordered">
							<tbody>
								<tr class="active">
									<th><strong>商品咨询</strong></th>
								</tr>
								<tr class="warning">
									<th>暂无商品咨询信息 <a>[发表商品咨询]</a></th>
								</tr>
							</tbody>
						</table>
					</div> -->
				</div>

			</div>
		</div>

		<%@ include file="under.jsp" %>

	</body>

</html>